const app = getApp()
const {getRouter} = require('../../utils/router.js')
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    showIndex: Number
  },
  /**
   * 组件的初始数据
   */
  data: {
    currentIndex: null,
    showList: false,
    isAdmin: false
  },
  ready () {
    this.router = getRouter()
    this.setData({
      isAdmin: app.globalData.isAdmin
    })
  },
  methods: {
    changePage (e) {
      this.changeEvent(e.currentTarget.dataset.index)
    },
    changeEvent (index) {
      if (index === this.data.showIndex) return
      this.router.navigateTo(index)
      this.closeList()
    },
    showList(){
      this.setData({
        showList: true
      })
    },
    closeList(){
      this.setData({
        showList: false
      })
    }
  }
})
